﻿using System;
using System.Text;

namespace GPS.GPSLanguage
{
    class SatelliteCountToken
    {
        internal static void ParseLanguage(GPSData gpsData, System.Collections.Queue q)
        {
            String satCountToken = (string)q.Dequeue();
            int satCount = 0;
            try
            {
                if(satCountToken.Length>0)
                    satCount = int.Parse(satCountToken);
            }
            catch { }

            if(gpsData.SentenceNumber==1)
                gpsData.SetSatelliteCount(satCount);

            switch (gpsData.MessageType)
            {
                case MessageType.GPGGA:
                    HorizontalDilutionToken.ParseLanguage(gpsData, q);
                    break;
                case MessageType.GPGSV:
                    PRNToken.ParseLanguage(gpsData, q);
                    break;
                default:
                    throw new InvalidLanguageException("How did you get here?");
            }

        }
    }
}
